<?php
/**
 * Created by PhpStorm.
 * User: xkq
 * Date: 2018/4/23 0023
 * Time: 23:29
 */
set_include_path(dirname(dirname(__FILE__)));
include_once("inc/init.php");
include 'function.php';
session_start();
global $db, $smarty;
$url = "http://dingwei.famishare.me/tosend.php?ordersn=".$_GET['ordersn'];
$code = getCode($url);
$access_token = getOpenId($code);
$userInfo = getUserInfo($access_token);
$smarty->assign('userInfo', $userInfo);
$ordersn = $_GET['ordersn'];
$sql = "SELECT * FROM `order` WHERE ordersn='{$ordersn}' and status=2";
$orderinfo = $db->get_row($sql);
if(!$orderinfo){
    alert_back('红包发送错误！！');
}

$cost = intval($orderinfo['cost']);
$smarty->assign('cost', $cost);
$smarty->assign('userid', $orderinfo['userid']);
$smarty->assign('ordersn', $ordersn);
if($orderinfo['use_status'] == 1){  //已领取
    $smarty->display('reciver.htm');
}else{   //未领取
    $smarty->assign('signPackage', getSignPackage());
    $smarty->display('recived.htm');
}